define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'user/flowingwater/index',
                    table: 'wallet_record',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                columns: [
                    [
                        {field:'username',title:'会员账号'},
                        {field: 'record.createtime', title: '入款时间', operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'recharge', title: '入款金额',operate:false},
                        {field: 'type_name', title: '类型',operate:false},
                        {field: 'bet', title: '有效投注额',operate:false},
                        {field: 'beallwate', title: '要求打码量', operate:false},
                        {
                            field: 'surpluswate',
                            title: '是否达到打码量',
                            operate:false,
                            formatter: function (val) {
                                if( val < 0 ){
                                    return '<span style="color: green;">' + val + '</span>';
                                }else{
                                    return '<span style="color: red;">否(' + val + ')</span>';
                                }
                            }
                        },
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});